import java.util.Random;
import java.util.Scanner;

public class tt {
    public static void main(String[] args) {
        // 创建随机数生成器
        Random rand = new Random();
        // 生成0-9的随机数
        int target = rand.nextInt(10);

        Scanner scanner = new Scanner(System.in);
        boolean isWin = false;

        // 3次猜测机会
        for(int i=0; i<3; i++){
            System.out.print("请输入数字（0-9）: ");
            int guess = scanner.nextInt();

            if(guess == target) {
                System.out.println("★中奖啦！★");
                isWin = true;
                break;
            }
            // 大小提示
            else if(guess > target) {
                System.out.println("猜大了！");
            } else {
                System.out.println("猜小了！");
            }

            // 剩余次数提示
            if(i < 2) {
                System.out.println("剩余机会：" + (2-i));
            }
        }

        // 未中奖显示答案
        if(!isWin) {
            System.out.println("\n正确答案是：" + target);
        }
        scanner.close();
    }
}